package com.mallcloud.mall.app.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.mallcloud.mall.app.api.entity.dto.AppXglQRCodePaymentInfoDTO;
import com.mallcloud.mall.app.api.entity.dto.AppXglQRCodePaymentLoginDTO;
import com.mallcloud.mall.app.api.entity.vo.XglQRCodePaymentInfoVO;
import com.mallcloud.mall.app.service.AppXglQRCodePaymentService;
import com.mallcloud.mall.common.core.util.R;
import com.mallcloud.mall.mall.api.entity.XglQRCodePaymentModel;
import com.mallcloud.mall.mall.service.XglQRCodePaymentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@Api(tags = "app-星光里二维码支付牌信息")
@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("/app/xglQRCodePayment")
@ConditionalOnProperty("const.pay.url")
public class AppXglQRCodePaymentController {
	private final XglQRCodePaymentService xglQRCodePaymentService;
	private final AppXglQRCodePaymentService appXglQRCodePaymentService;

	@ApiOperation("获取立牌信息详细信息")
	@GetMapping("/getInfo")
	public R<XglQRCodePaymentModel> getByMerchantCode(XglQRCodePaymentModel param) {
		return R.ok(xglQRCodePaymentService.getOne(new LambdaQueryWrapper<>(param)));
	}

	@ApiOperation("立牌商户登陆")
	@PostMapping("/merchantLogin")
	public R<Boolean> merchantLogin(@RequestBody AppXglQRCodePaymentLoginDTO dto) {
		return R.ok(appXglQRCodePaymentService.merchantLogin(dto));
	}

	@ApiOperation("2.6扫码支付（主扫）下单QrNative")
	@PostMapping("/getPayInfo")
	public R<XglQRCodePaymentInfoVO> getPayInfo(AppXglQRCodePaymentInfoDTO dto) {
		return R.ok(appXglQRCodePaymentService.getPayInfo(dto));
	}

	@ApiOperation("2.2异步通知")
	@PostMapping("/asyncNotices")
	public Map<String, Object> notify(HttpServletRequest request) {
		return appXglQRCodePaymentService.notify(request);
	}
}
